package droid.pkg.test;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

public class BallView extends View {

    public float x;
    public float y;
    private final int r;
    private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    
    //Updated Fields 11/10/2013
    //position
    public int mXCenter;
    public int mYCenter;
    // Speed
    public float mAx;
    public float mAy;
    
    
    
    //construct new ball object
    public BallView(Context context, float x, float y, int r) {
        this(context, x, y, r, 0xFFFF0000);
    }
    
    /**
     * 
     * @param context
     * @param x
     * @param y
     * @param r
     * @param color int - hex [transparency][red][green][blue]
     */
    public BallView(Context context, float x, float y, int r, int color) {
        super(context);
        //color hex is [transparency][red][green][blue]
        mPaint.setColor(color);  //not transparent. color is green
        this.x = x;
        this.y = y;
        this.r = r;  //radius
    }
        
    //called by invalidate()
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawCircle(x, y, r, mPaint);
    } 
    
    public void setColor(int color){
    	mPaint.setColor(color);
    	//this.invalidate();
    }
}